package com.jilian.mydemo.modul.order.viewmodel;

import android.arch.lifecycle.LiveData;

import com.jilian.mydemo.base.BaseDto;
import com.jilian.mydemo.base.BaseViewModel;
import com.jilian.mydemo.city.bean.ProvinceBean;
import com.jilian.mydemo.common.dto.AccountDto;
import com.jilian.mydemo.common.dto.CommitOrderDto;
import com.jilian.mydemo.common.dto.EvaluateDto;
import com.jilian.mydemo.common.dto.FinishImgDto;
import com.jilian.mydemo.common.dto.FinishPayDto;
import com.jilian.mydemo.common.dto.MemberDto;
import com.jilian.mydemo.common.dto.OrderDetailDto;
import com.jilian.mydemo.common.dto.OrderListDto;
import com.jilian.mydemo.common.dto.ParamsListDto;
import com.jilian.mydemo.common.dto.PerformDto;
import com.jilian.mydemo.common.dto.PerformListDto;
import com.jilian.mydemo.common.dto.PlanPathListDto;
import com.jilian.mydemo.common.dto.ProductDetailDto;
import com.jilian.mydemo.common.dto.ServiceProcessDto;
import com.jilian.mydemo.common.dto.ShopListDto;
import com.jilian.mydemo.common.vo.AddProductToOrderVo;
import com.jilian.mydemo.common.vo.DelayNoticeVo;
import com.jilian.mydemo.common.vo.FinishImgVo;
import com.jilian.mydemo.common.vo.FinishOrderVo;
import com.jilian.mydemo.common.vo.FinishPayVo;
import com.jilian.mydemo.common.vo.MemberVo;
import com.jilian.mydemo.common.vo.OrderVo;
import com.jilian.mydemo.common.vo.PerformanceVo;
import com.jilian.mydemo.common.vo.ProductToShoppingCartVo;
import com.jilian.mydemo.common.vo.ReportOrderVo;
import com.jilian.mydemo.common.vo.ServiceAreaVo;
import com.jilian.mydemo.common.vo.SubscribeVo;
import com.jilian.mydemo.common.vo.UpdateShopCartVo;
import com.jilian.mydemo.common.vo.UpdateWorkVo;
import com.jilian.mydemo.common.vo.VisitSignVo;
import com.jilian.mydemo.common.vo.WithdrawCountVo;
import com.jilian.mydemo.common.vo.WithdrawOrderVo;
import com.jilian.mydemo.common.vo.WithdrawVo;
import com.jilian.mydemo.factory.Factoty;
import com.jilian.mydemo.modul.order.repositoty.OrderRepository;

import java.io.File;
import java.util.List;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 订单相关 viewmodel
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class OrderViewModel extends BaseViewModel {
    /**
     * 订单列表
     */
    private LiveData<BaseDto<OrderListDto>> orderliveData;
    /**
     * 抢单
     */
    private LiveData<BaseDto> grabliveData;
    /**
     * 预约
     */
    private LiveData<BaseDto> subscribeliveData;

    /**
     * 延时提醒
     */
    private LiveData<BaseDto> delayNoticeliveData;

    /**
     * 查看服务进程
     */
    private LiveData<BaseDto<List<ServiceProcessDto>>> serviceProcessliveData;
    /**
     * 上门签到
     */
    private LiveData<BaseDto> visitSignliveData;

    /**
     * 水工报单
     */
    private LiveData<BaseDto> reportliveData;
    /**
     * 退单
     */
    private LiveData<BaseDto> withdrawliveData;
    /**
     * 退单次数
     */
    private LiveData<BaseDto<String>> withdrawCount;

    /**
     * 订单详情
     */
    private LiveData<BaseDto<OrderDetailDto>> detailliveData;

    /**
     * 水工績效
     */
    private LiveData<BaseDto<PerformListDto>> performanceliveData;

    /**
     * 水工评分
     */
    private LiveData<BaseDto<EvaluateDto>> evaluateDtoliveData;
    /**
     * 水工列表
     */
    private LiveData<BaseDto<List<MemberDto>>> memberliveData;//
    /**
     * 设置水工工作量
     */
    private LiveData<BaseDto> updateWorkliveData;//

    /**
     * 工单地图
     */
    private LiveData<BaseDto<PlanPathListDto>> planPathliveData;//
    /**
     * 上传凭据（表单提交）
     */
    private LiveData<BaseDto<List<FinishImgDto>>> finishImliveData;//

    private LiveData<BaseDto<FinishPayDto>> finishPayliveData;//

    /**
     * 服务列表
     */
    private LiveData<BaseDto<List<ProvinceBean>>> serviceArealiveData;//
    /**
     * 完成订单
     */
    private LiveData<BaseDto> finishliveData;//
    /**
     * 提交订单到支付
     */
    private LiveData<BaseDto<Long>> commitliveData;//

    /**
     * 加入购物车
     */
    private LiveData<BaseDto> addShopliveData;//
    /**
     * 查询购物车
     */
    private LiveData<BaseDto<List<ProductDetailDto>>> shopListliveData;//

    /**
     * 购物车-修改对应的购物车
     */
    private LiveData<BaseDto> addDelliveData;//


    /**
     * 添加到订单
     */
    private LiveData<BaseDto> addOrderliveData;//
    /**
     * 检查订单支付状态
     */
    private LiveData<BaseDto<String>> checkOrderliveData;//
    /**
     * 完成订单页面-初始化参数
     */
    private LiveData<BaseDto<ParamsListDto>> paramsliveData;//

    /**
     * 我的钱包
     */
    private LiveData<BaseDto<AccountDto>> accountliveData;//

    /**
     * 提现
     */
    private LiveData<BaseDto> withdrliveData;//

    /**
     * 报单下啦参数
     */
    private LiveData<BaseDto<ParamsListDto>> reportParamliveData;//

    /**
     * 检查是否签到
     */
    private LiveData<BaseDto<String>> checkSignliveData;//

    public LiveData<BaseDto<String>> getWithdrawCount() {
        return withdrawCount;
    }

    public LiveData<BaseDto<OrderListDto>> getOrderliveData() {
        return orderliveData;
    }

    public LiveData<BaseDto> getGrabliveData() {
        return grabliveData;
    }

    public LiveData<BaseDto> getSubscribeliveData() {
        return subscribeliveData;
    }

    public LiveData<BaseDto> getDelayNoticeliveData() {
        return delayNoticeliveData;
    }

    public LiveData<BaseDto<List<ServiceProcessDto>>> getServiceProcessliveData() {
        return serviceProcessliveData;
    }

    public LiveData<BaseDto> getVisitSignliveData() {
        return visitSignliveData;
    }

    public LiveData<BaseDto> getReportliveData() {
        return reportliveData;
    }

    public LiveData<BaseDto> getWithdrawliveData() {
        return withdrawliveData;
    }

    public LiveData<BaseDto<OrderDetailDto>> getDetailliveData() {
        return detailliveData;
    }

    public LiveData<BaseDto<PerformListDto>> getPerformanceliveData() {
        return performanceliveData;
    }

    public LiveData<BaseDto<EvaluateDto>> getEvaluateDtoliveData() {
        return evaluateDtoliveData;
    }

    public LiveData<BaseDto<List<MemberDto>>> getMemberliveData() {
        return memberliveData;
    }

    public LiveData<BaseDto> getUpdateWorkliveData() {
        return updateWorkliveData;
    }

    public LiveData<BaseDto<PlanPathListDto>> getPlanPathliveData() {
        return planPathliveData;
    }

    public LiveData<BaseDto<List<FinishImgDto>>> getFinishImliveData() {
        return finishImliveData;
    }

    public LiveData<BaseDto<FinishPayDto>> getFinishPayliveData() {
        return finishPayliveData;
    }

    public LiveData<BaseDto<List<ProvinceBean>>> getServiceArealiveData() {
        return serviceArealiveData;
    }

    public LiveData<BaseDto> getFinishliveData() {
        return finishliveData;
    }

    public LiveData<BaseDto<Long>> getCommitliveData() {
        return commitliveData;
    }

    public LiveData<BaseDto> getAddShopliveData() {
        return addShopliveData;
    }

    public LiveData<BaseDto<List<ProductDetailDto>>> getShopListliveData() {
        return shopListliveData;
    }

    public LiveData<BaseDto> getAddDelliveData() {
        return addDelliveData;
    }

    public LiveData<BaseDto> getAddOrderliveData() {
        return addOrderliveData;
    }

    public LiveData<BaseDto<String>> getCheckOrderliveData() {
        return checkOrderliveData;
    }

    public LiveData<BaseDto<ParamsListDto>> getParamsliveData() {
        return paramsliveData;
    }

    public LiveData<BaseDto<AccountDto>> getAccountliveData() {
        return accountliveData;
    }

    public LiveData<BaseDto> getWithdrliveData() {
        return withdrliveData;
    }

    public LiveData<BaseDto<ParamsListDto>> getReportParamliveData() {
        return reportParamliveData;
    }

    public LiveData<BaseDto<String>> getCheckSignliveData() {
        return checkSignliveData;
    }

    /**
     * 获取订单列表
     *
     * @param status 订单状态  状态：2.待抢单， 3 待预约，4 进行中 5 已完成 7 已取消
     */
    public void queryOrderList(Integer pageNum, Integer pageSize, Integer status, String queryKey) {
        OrderVo vo = new OrderVo();
        vo.setQueryKey(queryKey);
        vo.setStatus(status);
        vo.setPageNum(pageNum);
        vo.setPageSize(pageSize);
        orderliveData = Factoty.getRepository(OrderRepository.class).query(vo);
    }

    /**
     * 抢单
     *
     * @param id 订单ID
     */
    public void grabOrder(String id) {
        OrderVo vo = new OrderVo();
        vo.setId(id);
        grabliveData = Factoty.getRepository(OrderRepository.class).grabOrder(vo);
    }

    /**
     * @param orderId       订单id
     * @param bookStartTime 预约开始时间
     * @param bookEndTime   预约结束时间
     * @param remark        备注
     */
    public void subscribe(String orderId, String bookStartTime, String bookEndTime, String remark) {
        SubscribeVo vo = new SubscribeVo();
        vo.setOrderId(orderId);
        vo.setBookStartTime(bookStartTime);
        vo.setBookEndTime(bookEndTime);
        vo.setRemark(remark);
        subscribeliveData = Factoty.getRepository(OrderRepository.class).subscribe(vo);
    }


    /**
     * 延时提醒
     *
     * @param orderId
     */
    public void delayNotice(String orderId) {
        DelayNoticeVo vo = new DelayNoticeVo();
        vo.setOrderId(orderId);
        delayNoticeliveData = Factoty.getRepository(OrderRepository.class).delayNotice(vo);
    }

    /**
     * 查看服务进程
     *
     * @param orderId
     */
    public void serviceProcess(String orderId) {
        OrderVo vo = new OrderVo();
        vo.setOrderId(orderId);
        serviceProcessliveData = Factoty.getRepository(OrderRepository.class).serviceProcess(vo);
    }

    /**
     * 上们签到
     *
     * @param orderId
     * @param location
     */
    public void visitSign(String orderId, String location, List<File> files) {
        VisitSignVo vo = new VisitSignVo();
        vo.setOrderId(orderId);
        vo.setLocation(location);
        visitSignliveData = Factoty.getRepository(OrderRepository.class).visitSign(vo, files);
    }

    /**
     *
     * @param customerName 客户姓名
     * @param customerPhone 客户电话
     * @param serviceAddress 服务地点
     * @param bookStartTime 预约开始时间
     * @param bookEndTime  预约结束时间
     * @param bookRemark  备注
     * @param productCode 产品编码
     * @param serviceType 服务类型
     * @param orderId 订单ID
     * @param files 上传文件
     */
    public void reportOrder(String customerName, String customerPhone, String serviceAddress, String bookStartTime, String bookEndTime, String bookRemark, String productCode, String serviceType, String orderId, List<File> files) {
        ReportOrderVo vo = new ReportOrderVo();
        vo.setCustomerName(customerName);
        vo.setCustomerPhone(customerPhone);
        vo.setServiceAddress(serviceAddress);
        vo.setBookStartTime(bookStartTime);
        vo.setBookEndTime(bookEndTime);
        vo.setBookRemark(bookRemark);
        vo.setProductCode(productCode);
        vo.setServiceType(serviceType);
        vo.setOrderId(orderId);
        reportliveData = Factoty.getRepository(OrderRepository.class).reportOrder(vo, files);
    }

    /**
     * 退单
     *
     * @param orderId        订单ID
     * @param remark         备注
     * @param withdrawReason 原因
     */
    public void withdrawOrder(String orderId, String remark, String withdrawReason) {
        WithdrawOrderVo vo = new WithdrawOrderVo();
        vo.setOrderId(orderId);
        vo.setRemark(remark);
        vo.setWithdrawReason(withdrawReason);
        withdrawliveData = Factoty.getRepository(OrderRepository.class).withdrawOrder(vo);
    }

    /**
     * 退单次数
     */
    public void withdrawCount() {
        WithdrawCountVo vo = new WithdrawCountVo();
        withdrawCount = Factoty.getRepository(OrderRepository.class).withdrawCount(vo);
    }


    /**
     * 订单详情
     *
     * @param id
     */
    public void queryDetail(String id) {
        OrderVo vo = new OrderVo();
        vo.setId(id);
        detailliveData = Factoty.getRepository(OrderRepository.class).queryDetail(vo);
    }

    public void performance(Integer pageNum, Integer pageSize, Integer type) {
        PerformanceVo vo = new PerformanceVo();
        vo.setPageNum(pageNum);
        vo.setPageSize(pageSize);
        vo.setType(type);
        performanceliveData = Factoty.getRepository(OrderRepository.class).performance(vo);
    }

    /**
     * 水工评分
     */
    public void evaluate() {
        evaluateDtoliveData = Factoty.getRepository(OrderRepository.class).evaluate();
    }

    /**
     * 水工列表
     */
    public void queryMember(String id) {
        MemberVo vo = new MemberVo();
        vo.setOrderId(id);
        memberliveData = Factoty.getRepository(OrderRepository.class).queryMember(vo);
    }

    /**
     * 设置水工工作量
     *
     * @param id
     * @param workload
     */
    public void updateWork(String id, String workload) {
        UpdateWorkVo vo = new UpdateWorkVo();
        vo.setId(id);
        vo.setWorkload(workload);
        updateWorkliveData = Factoty.getRepository(OrderRepository.class).updateWork(vo);
    }

    /**
     * 工单地图
     */
    public void planPath() {
        planPathliveData = Factoty.getRepository(OrderRepository.class).planPath();
    }

    /**
     * 上传凭据（表单提交）
     *
     * @param chargeMoney
     * @param files
     * @param orderId
     * @param remark
     * @param reduceMoney
     */
    public void uploadFinishImg(String chargeMoney, List<File> files, String orderId, String remark, String reduceMoney) {
        FinishImgVo vo = new FinishImgVo();
        vo.setChargeMoney(chargeMoney);
        vo.setOrderId(orderId);
        vo.setRemark(remark);
        vo.setReduceMoney(reduceMoney);
        finishImliveData = Factoty.getRepository(OrderRepository.class).uploadFinishImg(vo, files);
    }

    /**
     * @param orderId
     * @param type
     * @param files
     */
    public void finishPay(String orderId, String type, List<File> files) {
        FinishPayVo vo = new FinishPayVo();
        vo.setOrderId(orderId);
        vo.setType(type);
        finishPayliveData = Factoty.getRepository(OrderRepository.class).finishPay(vo, files);
    }


    /**
     * 获取服务列表
     */
    public void queryAllOffice() {
        serviceArealiveData = Factoty.getRepository(OrderRepository.class).queryAllOffice();
    }

    /**
     * 完成订单
     *
     * @param orderId 订单ID
     * @param lists   服务产品集合
     */
    public void finishOrder(String orderId, List<FinishImgDto> lists) {
        FinishOrderVo vo = new FinishOrderVo();
        vo.setOrderId(orderId);
        vo.setLists(lists);
        finishliveData = Factoty.getRepository(OrderRepository.class).finishOrder(vo);
    }

    public void commitOrder(String orderId) {
        OrderVo vo = new OrderVo();
        vo.setOrderId(orderId);
        commitliveData = Factoty.getRepository(OrderRepository.class).commitOrder(vo);
    }


    /**
     * @param productId   商品ID
     * @param quantity    数量
     * @param actualPrice 价格
     */
    public void addProductToShoppingCart(String productId, String quantity, String actualPrice) {
        ProductToShoppingCartVo vo = new ProductToShoppingCartVo();
        vo.setProductId(productId);
        vo.setQuantity(quantity);
        vo.setActualPrice(actualPrice);
        addShopliveData = Factoty.getRepository(OrderRepository.class).addProductToShoppingCart(vo);
    }

    /**
     * 查询购物车
     */
    public void getShoppingCartProducts() {
        shopListliveData = Factoty.getRepository(OrderRepository.class).getShoppingCartProducts();
    }

    /**
     * 购物车-修改对应的购物车
     *
     * @param type
     * @param shopCartId
     */
    public void updateShopCart(String type, String shopCartId) {
        UpdateShopCartVo vo = new UpdateShopCartVo();
        vo.setShopCartId(shopCartId);
        vo.setType(type);
        addDelliveData = Factoty.getRepository(OrderRepository.class).updateShopCart(vo);
    }


    /**
     * 购物车ID
     *
     * @param shopIds
     */
    public void addProductToOrder(List<String> shopIds) {
        AddProductToOrderVo vo = new AddProductToOrderVo();
        vo.setShopIds(shopIds);
        addOrderliveData = Factoty.getRepository(OrderRepository.class).addProductToOrder(vo);
    }

    /**
     * 订单状态检查
     *
     * @param orderId
     */
    public void checkPayStatus(String orderId) {
        OrderVo vo = new OrderVo();
        vo.setOrderId(orderId);
        checkOrderliveData = Factoty.getRepository(OrderRepository.class).checkPayStatus(vo);
    }

    /**
     * 完成订单页面-初始化参数
     */
    public void initParams() {
        paramsliveData = Factoty.getRepository(OrderRepository.class).initParams();
    }

    /**
     * 我的钱包
     */
    public void account() {
        accountliveData = Factoty.getRepository(OrderRepository.class).account();
    }

    /**
     * 提现
     */
    public void withdraw(String money,String weixinAccount) {
        WithdrawVo vo = new WithdrawVo();
        vo.setMoney(money);
        vo.setWeixinAccount(weixinAccount);
        withdrliveData = Factoty.getRepository(OrderRepository.class).withdraw(vo);
    }

    /**
     * 报单-下拉參數
     */
    public void reportInitParam() {
        reportParamliveData = Factoty.getRepository(OrderRepository.class).reportInitParam();
    }

    /**
     * 判断是否已经签到
     *
     * @param orderId
     */
    public void checkSign(String orderId) {
        OrderVo vo = new OrderVo();
        vo.setOrderId(orderId);
        checkSignliveData = Factoty.getRepository(OrderRepository.class).checkSign(vo);
    }


}
